package _4_8;

import java.util.ArrayList;

public class Teacher extends Person {
	private ArrayList<Discipline> disciplines;

	public Teacher () {
		this.name = null;
		disciplines = new ArrayList<Discipline> ();
	}
	
	public Teacher (String name) {
		this.name = name;
		disciplines = new ArrayList<Discipline> ();
	}

	public Teacher (String name, ArrayList<Discipline> disciplines) {
		this.name = name;
		this.disciplines = disciplines;
	}

	public void addDiscipline (Discipline d) {
		this.disciplines.add (d);
	}

	public Discipline getDisciplineAt (int i) {
		try {
			return disciplines.get (i);
		} catch (IndexOutOfBoundsException e) {
			return null;
		}
	}

	public Discipline[] getDisciplines () {
		return (Discipline[]) this.disciplines.toArray ();
	}

	public void print () {
		System.out.println (this.name);
		for (Discipline d : disciplines) {
			d.print ();
		}
	}

	public boolean removeDisciplineAt (int i) {
		try {
			disciplines.remove (i);
			return true;
		} catch (IndexOutOfBoundsException e) {
			return false;
		}
	}
}
